/**
 * 配件模型
 */

import {
  Entity,
  Column,
  OneToOne,
  JoinColumn,
  CreateDateColumn,
  PrimaryColumn
} from "typeorm";
import { BblAttach } from "./attach.entity";

@Entity("BBL_PART")
export class BblPart {
  @PrimaryColumn({
    name: "PART_ID",
    type: "varchar",
    length: 50,
    comment: "配件ID"
  })
  partId: string;

  @Column({
    name: "PART_MAIN_NAME",
    type: "varchar",
    length: 255,
    nullable: false,
    comment: "配件主标题"
  })
  partMainName: string;

  @Column({
    name: "PART_SUB_NAME",
    type: "varchar",
    length: 255,
    nullable: false,
    comment: "配件副标题"
  })
  partSubName: string;

  @Column({
    name: "PART_PRICE",
    type: "int",
    nullable: false,
    comment: "配件价格"
  })
  partPrice: number;

  @OneToOne((type) => BblAttach, { createForeignKeyConstraints: false })
  @JoinColumn({
    name: "PART_IMG_ID",
    referencedColumnName: "attId"
  })
  partImg: BblAttach;

  @CreateDateColumn({
    type: "timestamp",
    name: "CREATE_AT"
  })
  createAt: Date;
}
